﻿namespace Neovolve.Extensibility.ReSharper
{
    using System;
    using JetBrains.Application;
    using JetBrains.ComponentModel;
    using JetBrains.ReSharper.Daemon;

    /// <summary>
    /// The <see cref="HighlightingRegistration"/>
    ///   class is used to register the highlightings of the plugin with ReSharper.
    /// </summary>
    [ShellComponentImplementation(ProgramConfigurations.ALL)]
    public class HighlightingRegistration : IShellComponent
    {
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            Dispose(true);

            GC.SuppressFinalize(this);
        }

        /// <summary>
        /// Inits this instance.
        /// </summary>
        public void Init()
        {
            const String Group = "Neovolve";

            HighlightingSettingsManager manager = HighlightingSettingsManager.Instance;

            manager.RegisterConfigurableSeverity(
                ConvertToClrTypeHighlighting.Name, Group, "Convert to CLR type.", "Converts an alias type to its CLR equivelent.", Severity.SUGGESTION);

            manager.RegisterConfigurableSeverity(
                ConvertToAliasTypeHighlighting.Name, 
                Group, 
                "Convert to alias type.", 
                "Converts a CLR type to its alias equivelent.", 
                Severity.DO_NOT_SHOW);
        }

        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing">
        /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.
        /// </param>
        protected virtual void Dispose(Boolean disposing)
        {
            if (Disposed)
            {
                return;
            }

            if (disposing)
            {
                // TODO: Dispose managed resources here
            }

            // TODO: Dispose unmanaged resources here
            Disposed = true;
        }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="HighlightingRegistration"/> is disposed.
        /// </summary>
        /// <value>
        /// <c>true</c> if disposed; otherwise, <c>false</c>.
        /// </value>
        private Boolean Disposed
        {
            get;
            set;
        }
    }
}